﻿<?xml version="1.0" encoding="utf-8" ?>
<c2eventsheet>
    <!--All the 'name' attributes are ignored by Construct 2 - they are there for readability only.-->
    <name>EventSheetLevelSelect</name>
    <events>
        <variable constant="0" name="gCurrentLevel" static="0" type="number">0</variable>
        <comment>TODO: Change LevelRows and LevelColumns to the number of levels that you want to have</comment>
        <variable constant="0" name="gLevelRows" static="0" type="number">4</variable>
        <variable constant="0" name="gLevelColumns" static="0" type="number">5</variable>
        <event-group collapsed="1" description="" title="Create LevelBoxes">
            <sub-events>
                <event-block>
                    <conditions>
                        <condition id="-2" name="On start of layout" type="System" />
                    </conditions>
                    <actions />
                    <sub-events>
                        <variable constant="0" name="x" static="0" type="number">0</variable>
                        <variable constant="0" name="y" static="0" type="number">0</variable>
                        <variable constant="0" name="LevelBoxSpacing" static="0" type="number">80</variable>
                        <variable constant="0" name="idxLevelNumber" static="0" type="number">1</variable>
                        <event-block>
                            <conditions>
                                <condition id="-14" name="Compare variable" type="System">
                                    <param id="0" name="Variable">x</param>
                                    <param id="1" name="Comparison">0</param>
                                    <param id="2" name="Value">0</param>
                                </condition>
                            </conditions>
                            <actions>
                                <action id="-9" name="Set value" type="System">
                                    <param id="0" name="Variable">x</param>
                                    <param id="1" name="Value">LevelBox.Width/2 + LayoutWidth/2 - (gLevelColumns*LevelBox.Width + ((gLevelColumns-1)*LevelBoxSpacing))/2</param>
                                </action>
                                <action id="-9" name="Set value" type="System">
                                    <param id="0" name="Variable">y</param>
                                    <param id="1" name="Value">LevelBox.Height/2 + LayoutHeight/2 - (gLevelRows*LevelBox.Height + ((gLevelRows-1)*LevelBoxSpacing))/2</param>
                                </action>
                            </actions>
                            <sub-events>
                                <event-block>
                                    <conditions>
                                        <condition id="-10" name="For" type="System">
                                            <param id="0" name="Name">&quot;&quot;</param>
                                            <param id="1" name="Start index">1</param>
                                            <param id="2" name="End index">gLevelRows</param>
                                        </condition>
                                    </conditions>
                                    <actions />
                                    <sub-events>
                                        <event-block>
                                            <conditions>
                                                <condition id="-10" name="For" type="System">
                                                    <param id="0" name="Name">&quot;&quot;</param>
                                                    <param id="1" name="Start index">1</param>
                                                    <param id="2" name="End index">gLevelColumns</param>
                                                </condition>
                                            </conditions>
                                            <actions>
                                                <action id="-3" name="Create object" type="System">
                                                    <param id="0" name="Object to create">LevelBox</param>
                                                    <param id="1" name="Layer">0</param>
                                                    <param id="2" name="X">x</param>
                                                    <param id="3" name="Y">y</param>
                                                </action>
                                                <action id="-9" name="Set value" type="System">
                                                    <param id="0" name="Variable">x</param>
                                                    <param id="1" name="Value">x + LevelBox.Width + LevelBoxSpacing</param>
                                                </action>
                                            </actions>
                                            <sub-events>
                                                <comment>Here we are creating a TextBox with level number on it, storing the level number in the LevelBox&apos;s instance variable Level</comment>
                                                <event-block>
                                                    <conditions />
                                                    <actions>
                                                        <action id="0" name="Spawn another object" type="LevelBox">
                                                            <param id="0" name="Object">txtLevelNumber</param>
                                                            <param id="1" name="Layer">1</param>
                                                            <param id="2" name="Image point">1</param>
                                                        </action>
                                                        <action id="-10" name="Set value" type="LevelBox">
                                                            <param id="0" name="Instance variable">Level</param>
                                                            <param id="1" name="Value">idxLevelNumber</param>
                                                        </action>
                                                        <action id="0" name="Set text" type="txtLevelNumber">
                                                            <param id="0" name="Text">idxLevelNumber</param>
                                                        </action>
                                                        <action id="-24" name="Move to top" type="txtLevelNumber" />
                                                        <action id="-10" name="Add to" type="System">
                                                            <param id="0" name="Variable">idxLevelNumber</param>
                                                            <param id="1" name="Value">1</param>
                                                        </action>
                                                    </actions>
                                                </event-block>
                                            </sub-events>
                                        </event-block>
                                        <event-block>
                                            <conditions />
                                            <actions>
                                                <action id="-9" name="Set value" type="System">
                                                    <param id="0" name="Variable">x</param>
                                                    <param id="1" name="Value">LevelBox.Width/2 + LayoutWidth/2 - (gLevelColumns*LevelBox.Width + ((gLevelColumns-1)*LevelBoxSpacing))/2</param>
                                                </action>
                                                <action id="-9" name="Set value" type="System">
                                                    <param id="0" name="Variable">y</param>
                                                    <param id="1" name="Value">y + LevelBox.Height + LevelBoxSpacing</param>
                                                </action>
                                            </actions>
                                        </event-block>
                                    </sub-events>
                                </event-block>
                            </sub-events>
                        </event-block>
                    </sub-events>
                </event-block>
            </sub-events>
        </event-group>
        <event-group collapsed="1" description="" title="Handle LevelBox Click">
            <sub-events>
                <event-block>
                    <conditions>
                        <condition id="3" name="On touched object" type="Touch">
                            <param id="0" name="Object">LevelBox</param>
                        </condition>
                    </conditions>
                    <actions>
                        <action behavior="Sine" id="0" name="Set active" type="LevelBox">
                            <param id="0" name="State">1</param>
                        </action>
                        <action id="-16" name="Wait" type="System">
                            <param id="0" name="Seconds">Button.sine.Period</param>
                        </action>
                        <action behavior="Sine" id="0" name="Set active" type="LevelBox">
                            <param id="0" name="State">0</param>
                        </action>
                    </actions>
                    <sub-events>
                        <event-block>
                            <conditions />
                            <actions>
                                <action id="-9" name="Set value" type="System">
                                    <param id="0" name="Variable">gCurrentLevel</param>
                                    <param id="1" name="Value">LevelBox.Level</param>
                                </action>
                                <action id="-3" name="Create object" type="System">
                                    <param id="0" name="Object to create">TransitionBackground</param>
                                    <param id="1" name="Layer">&quot;GUI&quot;</param>
                                    <param id="2" name="X">LayoutWidth/2</param>
                                    <param id="3" name="Y">LayoutHeight/2</param>
                                </action>
                                <action id="-7" name="Set size" type="TransitionBackground">
                                    <param id="0" name="Width">LayoutWidth</param>
                                    <param id="1" name="Height">LayoutHeight</param>
                                </action>
                                <action id="-10" name="Set value" type="TransitionBackground">
                                    <param id="0" name="Instance variable">TargetLayout</param>
                                    <param id="1" name="Value">&quot;LayoutLevel&quot; &amp; LevelBox.Level</param>
                                </action>
                                <action behavior="Fade" id="1" name="Start fade" type="TransitionBackground" />
                            </actions>
                        </event-block>
                        <event-block>
                            <conditions>
                                <condition id="-19" name="Pick all" type="System">
                                    <param id="0" name="Object">LevelBox</param>
                                </condition>
                            </conditions>
                            <actions>
                                <action id="-9" name="Destroy" type="LevelBox" />
                            </actions>
                        </event-block>
                        <event-block>
                            <conditions>
                                <condition id="-19" name="Pick all" type="System">
                                    <param id="0" name="Object">txtLevelNumber</param>
                                </condition>
                            </conditions>
                            <actions>
                                <action id="-9" name="Destroy" type="txtLevelNumber" />
                            </actions>
                        </event-block>
                    </sub-events>
                </event-block>
                <event-block>
                    <conditions>
                        <condition behavior="Fade" id="0" name="On fade out finished" type="TransitionBackground" />
                    </conditions>
                    <actions>
                        <action id="-25" name="Go to layout (by name)" type="System">
                            <param id="0" name="Layout">TransitionBackground.TargetLayout</param>
                        </action>
                    </actions>
                </event-block>
            </sub-events>
        </event-group>
        <event-group collapsed="1" description="" title="Mouse Cursor to Hand">
            <sub-events>
                <event-block>
                    <conditions>
                        <condition id="7" name="Cursor is over object" type="Mouse">
                            <param id="0" name="Object">LevelBox</param>
                        </condition>
                    </conditions>
                    <actions>
                        <action id="0" name="Set cursor style" type="Mouse">
                            <param id="0" name="Cursor style">1</param>
                        </action>
                    </actions>
                </event-block>
                <event-block>
                    <conditions>
                        <condition id="-22" name="Else" type="System" />
                    </conditions>
                    <actions>
                        <action id="0" name="Set cursor style" type="Mouse">
                            <param id="0" name="Cursor style">0</param>
                        </action>
                    </actions>
                </event-block>
            </sub-events>
        </event-group>
    </events>
</c2eventsheet>
